<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>委托历史</title>
<script type="text/javascript">
	var $grid;
	var selectTableRow;//选中的行数据
	$(function() {
		$grid = $("#grid").datagrid($.extend(datagridOption,{
			url : "${ctx}/bpm/delegateHistory/dataGrid",
			columns : [ [ {
				field : 'ck',
				checkbox : true
			}, {
				field : 'assignee',
				title : '委托人',
				sortable : true,
				formatter : function(value, row, index) {
					return value ? value.trueName : "";
				}
			}, {
				field : 'attorney',
				title : '被委托人',
				sortable : true,
				formatter : function(value, row, index) {
					return value ? value.trueName : "";
				}
			}, {
				field : 'delegateTime',
				title : '委托时间',
				sortable : true
			}, {
				field : 'taskId',
				title : '任务ID',
				sortable : true
			}, {
				field : 'taskDefinitionKey',
				title : '任务定义KEY',
				sortable : true
			}, {
				field : 'processInstanceId',
				title : '流程实例ID',
				sortable : true
			}, {
				field : 'processDefinitionId',
				title : '流程定义ID',
				sortable : true
			}, {
				field : 'status',
				title : '是否有效',
				sortable : true,
				formatter : function(value, row, index) {
					return value==1 ? "是" : "否";
				}
			} ] ]
		}));
		$grid.datagrid('enableFilter', [ {
			field : 'assignee',
			searchField : 'assignee.trueName'
		}, {
			field : 'attorney',
			searchField : 'attorney.trueName'
		}, {
			field : 'status',
			type : 'combobox',
			javaType : 'I',
			options : {
				panelHeight : 'auto',
				data : [ {
					value : '',
					text : '全部'
				}, {
					value : '1',
					text : '是'
				}, {
					value : '2',
					text : '否'
				} ],
				onChange : function(value) {
					if (value == '') {
						$("#grid").datagrid('removeFilterRule', 'status');
					} else {
						$("#grid").datagrid('addFilterRule', {
							field : 'status',
							op : 'EQ',
							value : value
						});
					}
					$("#grid").datagrid('doFilter');
				}
			}
		} ]);
		$("#delete").click(function() {
			var rowData = $grid.datagrid("getSelected");
			if (rowData == null) {
				$.messager.show({
					msg : "您未选中行，无法删除",
					icon : "warning",
					position : "bottomRight"
				});
			} else {
				$.messager.confirm("您确定要进行该操作？", function(c) {
					if (c) {
						$.get("${ctx}/bpm/delegateHistory/delete/" + rowData.id, function(result) {
							$.messager.show({
								msg : result.msg,
								icon : "info",
								position : "bottomRight"
							});
							if (result.success) {
								$grid.datagrid("deleteRow", rowData);
							}
						}, 'json');
					}
				});
			}
		});
		$("#excelExport").click(function() {
			window.parent.location.href = "${ctx}/bpm/delegateHistory/excelExport?" + $.param($grid.datagrid('options').queryParams);
		});
	});
</script>
</head>

<body>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid">
		</table>
	</div>
	<div id="tt" style="padding: 5px; height: auto">
		<div style="margin-bottom: 5px">
		<div class="row">
		<div class="col-md-12">
		</div>
		</div>
		<shiro:hasPermission name="bpmDelegateHistory:update">
			<button id="add" type="button" class="btn btn-primary">
					<span class="glyphicon glyphicon-plus"></span> 新增
				</button>
			</shiro:hasPermission>
			<shiro:hasPermission name="bpmDelegateHistory:delete">
			<button id="delete" type="button" class="btn btn-danger">
					<span class="glyphicon glyphicon-minus"></span> 删除
				</button>
			</shiro:hasPermission>
			<shiro:hasPermission name="bpmDelegateHistory:export">
			<button id="excelExport" type="button" class="btn btn-primary">
					<span class="glyphicon glyphicon-save"></span> Excel导出
				</button>
			</shiro:hasPermission>
		</div>
	</div>
</body>
</html>
